import { createApp } from 'vue'
import "./mock"
import App from './App.vue'
import { create } from 'naive-ui'
import router from './router'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import { useSysClassStore } from './stores/class.ts' // 请根据你的实际路径调整
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue' // <--- 导入所有图标
import 'element-plus/dist/index.css'


const app = createApp(App)
const pinia = createPinia()

pinia.use(piniaPluginPersistedstate);
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(pinia)
app.use(create())
app.use(router)


app.mount('#app')






function loadTestData() {
    const classStore = useSysClassStore()

    // 定义测试数据
    const initialTestData = [
        {
            id: 1,
            teacherId: 103,
            teacherName:'Mr. Smith Teacher',
            studentName:['Jane Student'],
            className: '高三一班',
            studentId: [102],
        },
        {
            id: 2,
            teacherId: 103,
            className: '高三二班',
            studentId: [1758792508003,102],
            teacherName:'Mr. Smith Teacher',
            studentName:['Jane Student'],
        },
        {
            id: 3,
            teacherId: 103, // 同一个老师教两个班
            className: '高二一班',
            studentId: [],
            teacherName:'Mr. Smith Teacher',
            studentName:[],
        },
    ];

// 检查 Store 是否为空，如果为空则加载测试数据，避免刷新页面后重复加载
    if (classStore.getAllClasses.length === 0) {
        console.log('正在加载班级测试数据...')
        // 由于我们的 addClass 会生成新ID，我们直接操作 state 来设置初始数据
        // 在真实项目中，这里应该是一个从 API 获取数据的调用
        classStore.$patch((state) => {
            state.sysClassList = initialTestData;
        });
        console.log('班级测试数据加载完成！')
    }
}


loadTestData();

